<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<script type="text/javascript">
	$(function() {
		$('#user_login_loginForm').form({
			url : '${pageContext.request.contextPath}/userAction!login.action',
			success : function(msg) {
				var obj = jQuery.parseJSON(msg);
				if (obj.success) {
					$('#user_login_loginDialog').dialog('close');
					$('#layout_west_tree').tree({
						url : '${pageContext.request.contextPath}/menuAction!getAllTreeNode.action',
						parentField : 'pid',

						//lines : true,
						onClick : function(node) {
							if (node.attributes && node.attributes.url) {
								var url;
								var iframe;
								if (node.attributes.url.indexOf('/') == 0) {
									url = '${pageContext.request.contextPath}' + node.attributes.url;
								} else {
									url = node.attributes.url;
								}
								//iframe = '<iframe src="' + url + '" frameborder="0" style="border:0;width:100%;height:98%;" sandbox></iframe>';
								iframe = '<iframe src="' + url + '" frameborder="0" style="border:0;width:100%;height:98%;"></iframe>';
								var t = $('#index_tabs');
								var opts = {
									title : node.text,
									closable : true,
									iconCls : node.iconCls,
									content : iframe,
									border : false
								};
								if (t.tabs('exists', opts.title)) {
									t.tabs('select', opts.title);
								} else {
									t.tabs('add', opts);
								}
							}
						}
					});

				} else {
					$('#user_login_loginForm').form('clear');
				}
				$.messager.show({
					title : '提示',
					msg : obj.msg
				});
			}
		});
		$('#user_login_loginForm input').bind('keyup', function(event) {/* 增加回车提交功能 */
			if (event.keyCode == '13') {
				$('#user_login_loginForm').submit();
			}
		});

		window.setTimeout(function() {
			$('#user_login_loginForm input[name=userNicheng]').focus();
		}, 0);
	});
</script>
<div class="easyui-dialog" id="user_login_loginDialog" data-options="title:'登录框',modal:true,closable:false,buttons:[{
				text:'登录',
				iconCls:'icon-save',
				handler:function(){
					$('#user_login_loginForm').submit();
				}
			}]">
	<form id="user_login_loginForm" method="post">
		<table>
			<tr>
				<th>登录名:</th>
				<td><input name="userNicheng" type="text" class="easyui-validatebox" data-options="required:true,missingMessage:'登陆名称必填'" /></td>
			</tr>
			<tr>
				<th>密&nbsp;&nbsp;&nbsp;&nbsp;码:</th>
				<td><input type="password" name="userPwd" class="easyui-validatebox" data-options="required:true,missingMessage:'密码必填'" /></td>
			</tr>
		</table>
	</form>

</div>
